package yz.com.javautil.date;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Administrator
 */
public class GenDateTime {
    public static void main(String[] args) {
        // 定义起始和结束时间的字符串表示
        String startStr = "2025-08-05 09:00:00";
        String endStr = "2025-08-06 23:59:59";

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime startTime = LocalDateTime.parse(startStr, formatter);
        LocalDateTime endTime = LocalDateTime.parse(endStr, formatter);
        List<LocalDateTime> times = new ArrayList<>();
        LocalDateTime current = startTime;
        while (!current.isAfter(endTime)) {
            times.add(current);
            current = current.plusMinutes(15);
        }
        List<Date> dateList = times.stream().map(t -> Date.from(t.atZone(ZoneId.systemDefault()).toInstant())).collect(Collectors.toList());

        // 打印结果
        System.out.println("Generated Times (every half hour):");
        for (Date t : dateList) {
            String currentCron = DateUtils.formatDate(t,"HH:mm");
            System.out.println(currentCron);
        }
    }

}
